package com.homedo.odin.solution.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.homedo.core.common.base.service.BaseService;
import com.homedo.odin.solution.dao.BountyMapper;
import com.homedo.odin.solution.model.dto.BountyBean;
import com.homedo.odin.solution.model.dto.PageBean;
import com.homedo.odin.solution.model.entity.Bounty;
import java.util.List;
import org.springframework.stereotype.Service;

/**
 * <p> 悬赏 服务实现类 </p>
 *
 * @author HarveyDing
 * @since 2018-03-08
 */
@Service
public class BountyServiceImpl extends BaseService<BountyMapper, Bounty> {

    /**
     * 获取首页每日悬赏
     */
    public List<Bounty> topbountys(int top) {
        return baseMapper.topbountys(top);
    }

    /**
     * 发布悬赏
     */
    public int publish(Bounty bounty) {
        return baseMapper.insert(bounty);
    }

    /**
     * 高赏金查询
     */
    public List<Bounty> highMoneyBountys(int top) {
        return baseMapper.highMoneyBountys(top);
    }

    /**
     * 获取悬赏列表
     */
    public PageInfo<BountyBean> getBountyList(PageBean pageBean, int userId, int bountyType, String status,
            long startTime, long endTime) {
        PageHelper.startPage(pageBean.getCurrentPage(), pageBean.getPageSize());
        return new PageInfo<BountyBean>(baseMapper.getBountyList(userId, bountyType, status, startTime, endTime));
    }

    /**
     * 获取悬赏详情
     */
    public Bounty checkBounty(int id) {
        return baseMapper.checkBounty(id);
    }
}
